home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 6 / ads / s-stratt < prev    next >
Text File  |  1996-02-12  |  8KB  |  166 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --             S Y S T E M . S T R E A M _ A T T R I B U T E S              --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.2 $                              --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc.     --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. --  This package contains the implementations of the stream attributes for
  37. --  elementary types. These are the subprograms that are directly accessed
  38. --  by occurrences of the stream attributes where the type is elementary.
  39.  
  40. --  We only provide the subprograms for the standard base types. For user
  41. --  defined types, the subprogram for the corresponding root type is called
  42. --  with an appropriate conversion.
  43.  
  44. with System;
  45. with System.Unsigned_Types;
  46. with Ada.Streams;
  47.  
  48. package System.Stream_Attributes is
  49. pragma Preelaborate (Stream_Attributes);
  50.  
  51.    package UST renames System.Unsigned_Types;
  52.  
  53.    subtype RST is Ada.Streams.Root_Stream_Type'Class;
  54.  
  55.    --  Enumeration types are usually transferred using the routine for the
  56.    --  corresponding integer. The exception is that special routines are
  57.    --  provided for Boolean and the character types, in case the protocol
  58.    --  in use provides specially for these types.
  59.  
  60.    --  Access types use either a thin pointer (single address) or fat pointer
  61.    --  (double address) form. The following types are used to hold access
  62.    --  values using unchecked conversions.
  63.  
  64.    type Thin_Pointer is record
  65.       P1 : System.Address;
  66.    end record;
  67.  
  68.    type Fat_Pointer is record
  69.       P1 : System.Address;
  70.       P2 : System.Address;
  71.    end record;
  72.  
  73.    --  Functions for S'Input attribute. These functions are also used for
  74.    --  S'Read, with the obvious transformation, since the input operation
  75.    --  is the same for all elementary types (no bounds or discriminants
  76.    --  are involved).
  77.  
  78.    function I_AD  (Stream : access RST) return Fat_Pointer;
  79.    function I_AS  (Stream : access RST) return Thin_Pointer;
  80.    function I_B   (Stream : access RST) return Boolean;
  81.    function I_C   (Stream : access RST) return Character;
  82.    function I_F   (Stream : access RST) return Float;
  83.    function I_I   (Stream : access RST) return Integer;
  84.    function I_LF  (Stream : access RST) return Long_Float;
  85.    function I_LI  (Stream : access RST) return Long_Integer;
  86.    function I_LLF (Stream : access RST) return Long_Long_Float;
  87.    function I_LLI (Stream : access RST) return Long_Long_Integer;
  88.    function I_LLU (Stream : access RST) return UST.Long_Long_Unsigned;
  89.    function I_LU  (Stream : access RST) return UST.Long_Unsigned;
  90.    function I_SF  (Stream : access RST) return Short_Float;
  91.    function I_SI  (Stream : access RST) return Short_Integer;
  92.    function I_SSI (Stream : access RST) return Short_Short_Integer;
  93.    function I_SSU (Stream : access RST) return UST.Short_Short_Unsigned;
  94.    function I_SU  (Stream : access RST) return UST.Short_Unsigned;
  95.    function I_U   (Stream : access RST) return UST.Unsigned;
  96.    function I_WC  (Stream : access RST) return Wide_Character;
  97.  
  98.    --  Procedures for S'Write attribute. These procedures are also used
  99.    --  for 'Output, since for elementary types there is no difference
  100.    --  between 'Write and 'Output because there are no discriminants
  101.    --  or bounds to be written.
  102.  
  103.    procedure W_AD  (Stream : access RST; Item : in Fat_Pointer);
  104.    procedure W_AS  (Stream : access RST; Item : in Thin_Pointer);
  105.    procedure W_B   (Stream : access RST; Item : in Boolean);
  106.    procedure W_C   (Stream : access RST; Item : in Character);
  107.    procedure W_F   (Stream : access RST; Item : in Float);
  108.    procedure W_I   (Stream : access RST; Item : in Integer);
  109.    procedure W_LF  (Stream : access RST; Item : in Long_Float);
  110.    procedure W_LI  (Stream : access RST; Item : in Long_Integer);
  111.    procedure W_LLF (Stream : access RST; Item : in Long_Long_Float);
  112.    procedure W_LLI (Stream : access RST; Item : in Long_Long_Integer);
  113.    procedure W_LLU (Stream : access RST; Item : in UST.Long_Long_Unsigned);
  114.    procedure W_LU  (Stream : access RST; Item : in UST.Long_Unsigned);
  115.    procedure W_SF  (Stream : access RST; Item : in Short_Float);
  116.    procedure W_SI  (Stream : access RST; Item : in Short_Integer);
  117.    procedure W_SSI (Stream : access RST; Item : in Short_Short_Integer);
  118.    procedure W_SSU (Stream : access RST; Item : in UST.Short_Short_Unsigned);
  119.    procedure W_SU  (Stream : access RST; Item : in UST.Short_Unsigned);
  120.    procedure W_U   (Stream : access RST; Item : in UST.Unsigned);
  121.    procedure W_WC  (Stream : access RST; Item : in Wide_Character);
  122.  
  123. private
  124.  
  125.    pragma Inline (I_AD);
  126.    pragma Inline (I_AS);
  127.    pragma Inline (I_B);
  128.    pragma Inline (I_C);
  129.    pragma Inline (I_F);
  130.    pragma Inline (I_I);
  131.    pragma Inline (I_LF);
  132.    pragma Inline (I_LI);
  133.    pragma Inline (I_LLF);
  134.    pragma Inline (I_LLI);
  135.    pragma Inline (I_LLU);
  136.    pragma Inline (I_LU);
  137.    pragma Inline (I_SF);
  138.    pragma Inline (I_SI);
  139.    pragma Inline (I_SSI);
  140.    pragma Inline (I_SSU);
  141.    pragma Inline (I_SU);
  142.    pragma Inline (I_U);
  143.    pragma Inline (I_WC);
  144.  
  145.    pragma Inline (W_AD);
  146.    pragma Inline (W_AS);
  147.    pragma Inline (W_B);
  148.    pragma Inline (W_C);
  149.    pragma Inline (W_F);
  150.    pragma Inline (W_I);
  151.    pragma Inline (W_LF);
  152.    pragma Inline (W_LI);
  153.    pragma Inline (W_LLF);
  154.    pragma Inline (W_LLI);
  155.    pragma Inline (W_LLU);
  156.    pragma Inline (W_LU);
  157.    pragma Inline (W_SF);
  158.    pragma Inline (W_SI);
  159.    pragma Inline (W_SSI);
  160.    pragma Inline (W_SSU);
  161.    pragma Inline (W_SU);
  162.    pragma Inline (W_U);
  163.    pragma Inline (W_WC);
  164.  
  165. end System.Stream_Attributes;
  166.